package apIExercise.String;

public class stringbulderDemo {
    public static void main(String[] args) {
        String str = "好好学习Java";
        StringBuilder builder = new StringBuilder(str);

        //追加
        builder.append(",月月50个w");
        System.out.println(builder);

        //替换
        builder.replace(9, 16, "我要当大哥");
        System.out.println(builder);

        //删除
        builder.delete(0, 8);
        System.out.println(builder);

        //插入
        builder.insert(0, "阿芬");
        System.out.println(builder);

        //StringBuilder的创建方式：

        StringBuilder builder1 = new StringBuilder();
        StringBuilder builder2 = new StringBuilder("abc");

//        String和StringBuulder互转
        String str1 = "abc";
        StringBuilder builder3 = new StringBuilder(str);
        String str2 = builder3.toString();
    }
}
